<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@page import="java.io.*,java.util.*,java.sql.*,com.animal.dao.*" %>
<html lang="zh-CN">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
	 	<title>注册结果</title>
	 	<link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.min.css">
	</head>
	<body>
		<nav class="navbar navbar-default">
 			<div class="container-fluid">
  				<div class="navbar-header">
   					<a class="navbar-brand" href="./" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >实验动物档案管理系统</a>
  				</div>
  				<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
   					<ul class="nav navbar-nav navbar-right">
    					<li>
    						<a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登录</a>
    					</li>
   					</ul>
  				</div>
 			</div>
		</nav>
		<div class="container">
 			<% 
 			String username = request.getParameter("UserID");
 			String password = request.getParameter("password"); 
 			String password2 = request.getParameter("password2"); 
 			
 			if(password.equals(password2)){
 				try{
	 				String queryStr = "insert into animalfile09_systemuser(UserID,Password) values(?,?) ";
					Connection conn = Connect.getCon();
					PreparedStatement pstmt = conn.prepareStatement(queryStr);
		  			pstmt.setString(1,username);
		  			pstmt.setString(2,password);
					pstmt.executeUpdate();
				}catch(SQLException e){
			%>
				<script type="text/javascript" language="javascript">
     			alert("用户ID已存在!");
     			window.document.location.href="Register.jsp";
    			</script> 
			<%		
				}
 			%>
 				<script type="text/javascript" language="javascript">
     			alert("注册成功!");
     			window.document.location.href="login.jsp";
    			</script> 
			<%
			}
 			else{
 			%>
 				<script type="text/javascript" language="javascript">
     			alert("两次密码输入不一致，请重新输入!");
     			window.document.location.href="Register.jsp";
    			</script> 
  			<%
 			}
 			%>
		</div>
	</body>
</html>